Skip to content

Use reticulate's py_require() to manage the Python installation and environment#82

Merged
jorainer merged 27 commits intomainfrom
py_require
Aug 26, 2025
Merged

Use reticulate's py_require() to manage the Python installation and environment#82
jorainer merged 27 commits intomainfrom
py_require

Conversation

@jorainer
Copy link
Member

This PR changes from the manual conda/virtualenv-based Python library installation to the newer, and recommended reticulate::py_require()-based approach (see also issue #81). This simplifies the code considerably.

Installation documentation was updated accordingly and a new troubleshooting section added (based on experiences and issues described in issue #81 ).

jorainer added 24 commits July 2, 2025 11:03
- Change to the new suggested `py_require()` functions from *reticulate* (issue
  #81).
- Update the README pointing to the new configuration.
- Update the installation instruction vignette.
- Add tolerance to spectrum_utils rtime comparison.
- Update information in vignette about Python configuration.
- Check environment variables on package loading to display warnings.
@jorainer jorainer requested a review from mdgrv August 22, 2025 06:06
@sec-python for options to skip this and use either *miniconda* or system Python
environment instead.
`install.packages("BiocManager")`. As a system dependency, the package requires
Python (version >= 2.12) to be available. During package installation,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.12, no idea >= or > (in read me it is ">")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! it's >= 3.12 - so I'll also fix in README.


1) Check the output of `Sys.getenv()`: is there a system variable
`RETICULATE_PYTHON` or `RETICULATE_PYTHON_ENV` defined? Problem: *reticulate*
will by use the specified Python or Python environment and skip automatic
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm "by"

evaluate if the required Python libraries (i.e. *matchms* version 0.28.2 and
*spectrum_utils* version 0.3.2-0) are available. If they are not available,
evaluate if the required Python libraries (i.e., *matchms* version 0.30.0 and
*spectrum_utils* version 0.3.2) are available. If they are not available,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe write the numpy version too, for completeness?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= 2.2.0.

DESCRIPTION Outdated
@@ -53,7 +53,7 @@ Authors@R: c(person(given = "Michael", family = "Witting",
)
Depends:
R (>= 4.1.0),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R >= 4.4.0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaah, good point. I'll update that.

*spectrum_utils* version 0.3.2) are available. If they are not available,
*SpectriPy* will install them using functionality from the *reticulate* R
package (see also
package, in particular, *reticulate*'s `py_require()` function (see also
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave out this 1 sentence regarding py_require(). Clear with "note" and "introduction" sections above.

Copy link
Collaborator

@mdgrv mdgrv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clearly explained the big changes. See smaller suggestions in single comments. The bigger suggestion (but you can leave it as such too), is to move the 2 appendix notes "sec-python" and "sec-fix" under appendices in the vignette: "detailed-installation-configuration.qmd". The reason is, I don't expect difficulties for 1st time installers (section Installation), as everything is installed in the background for them. if you want something more advanced, you go to the detailed install vignette.

@jorainer
Copy link
Member Author

Thank you so much for the review @mdgrv ! I will also move the two sections to the installation vignette as you suggested - makes more sense to have all configuration and installation related information in there.

@jorainer jorainer merged commit e09cc13 into main Aug 26, 2025
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants